Skip to content

Parse lists of word timestamps in SegLST JSON - #134

Open
antonsoo wants to merge 1 commit into
fgnt:mainfrom
antonsoo:fix/seglst-word-timestamp-lists
Open

antonsoo wants to merge 1 commit into
fgnt:mainfrom
antonsoo:fix/seglst-word-timestamp-lists

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

SegLST supports lists of word timestamps, and split_words(..., segment_representation='segment') produces them. Writing those segments to JSON and reading them back with the default reader raises ValueError because the complete list is passed to Decimal:

from meeteval.io import SegLST

text = '[{"session_id": "recording", "words": ["a", "b"], "start_time": [0.0, 0.5], "end_time": [0.5, 1.0]}]'
SegLST.parse(text)
# Before: ValueError: argument must be a sequence of length 3

Parse each timestamp in a list with the existing converter, retaining the scalar path. This also converts string timestamps when parse_float=float; empty lists remain empty.

Thirteen regression cases fail before; all 16 pass after, including JSON and file round trips for five existing timing strategies. On recorded LibriCSS transcript excerpts, 25 of 30 persistence/converter cases fail before and all 30 pass after. Parsed words/times and native cpWER/tcpWER results match the in-memory controls after explicitly flattening the word timestamps; ten scalar-timestamp controls remain identical. Direct scoring of unflattened list timestamps has a separate existing preprocessing failure and is outside this change.

Local Linux/Python3.12 test directory: 407 passed, 144 skipped, one existing warning. Package doctests and Windows were not run.

@boeddeker

Copy link
Copy Markdown
Member

Hmm. Thanks for the PR, do you have a motivation to support this input format? The list values for words, start_time and end_time are an internal representation. The idea was that users provide an entry per word when they want to skip the subsegmentation.

@antonsoo

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying. The motivation was saving the output of split_words(..., segment_representation='segment') and loading it again while retaining the original segment grouping. I inferred that round trip from the SegLstSegment annotations and SegLST.dump/load; this was found during validation, rather than reported by an external user.

For the intended input format, flattening with split_words(data, keys=('words', 'start_time', 'end_time')) before saving already gives a working round trip on the current code. So this PR is only useful if persistence of that internal grouping is something you want to support. If it should stay internal, I can close this.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants